package designMode.factoryPattern;

/**
 * 陆离
 * 2023/11/9 15:05:59
 */
public enum VisitEnum {
    FILE("file",new FileLog()),
    DATABASE("database",new DatabaseLog()),
    CONSOLE("console",new ConsoleLog());

    private String visit;
    private ILog iLog;

    VisitEnum(String visit,ILog iLog) {
        this.visit = visit;
        this.iLog = iLog;
    }

    public static ILog getVisit(String key) {
        for (VisitEnum value : VisitEnum.values()) {
            if (key.equals(value.visit)) {
                return value.iLog;
            }
        }
        return null;
    }

    public void setVisit(String visit,ILog iLog) {
        this.visit = visit;
        this.iLog = iLog;
    }

    public static void main(String[] args) {
        System.out.println(getVisit("file"));
    }
}
